package cAplicationLayer;

import java.rmi.RMISecurityManager;
import java.rmi.RemoteException;

import servidor.IServidorRMI;

public class ClienteRMI {

	static ClienteRMI cRMI;
	
	private IServidorRMI objServer;

	private ClienteRMI(){
	if (System.getSecurityManager() == null)
		System.setSecurityManager(new RMISecurityManager());
		try {
		String name = "//127.0.0.1:1099/ServerRMI";
		 objServer = (IServidorRMI) java.rmi.Naming.lookup(name);
		} catch (Exception e) {
		System.err.println("Cliente.main(): " + e.getMessage());
		e.printStackTrace();
		}
	}
	public int validarDatosEnServidor(String a, String b) {
		
		try {
			return objServer.validarDatos(a, b);
		} catch (RemoteException e) {
			e.printStackTrace();
			return 6;
			
		}
	}
	public static ClienteRMI getInstance() {
		
		if(cRMI == null)
			cRMI = new ClienteRMI();
		return cRMI;
	}
	
}
